package com.xc.c1

object gouzao {

  def main(args: Array[String]): Unit = {
    val p = new Person("hxc", 18)
    println(p.toString)

    val p2 = new Person("hxc2")
    println(p2.toString)
  }

  class Person(inName: String, inAge: Int) {
    var name: String = inName
    var age: Int = inAge
    println(" init ")

    override def toString = s"Person($name, $age)"

    //辅助构造器
    def this(inName:String){
      this("jack",18) //必须先调用主构造器
      this.name = inName
    }

  }

}
